#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <qfile.h>

#include <ui/module/formimi.h>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
    ui(new Ui::MainWindow)
    , _QStackedWidget(new QStackedWidget())
{
    ui->setupUi(this);
    //初始化左边的菜单
    initMenu();
    initRight();
}
//初始化右边容器
void MainWindow::initRight(){
    _QStackedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    ui->verticalLayout_2->addWidget(_QStackedWidget,1);

    FormImi* formImi = new FormImi();
    QWidget * widget = formImi->moduleView();
    _QStackedWidget->addWidget( widget );
    _QStackedWidget->setCurrentWidget(widget);
}
//初始化菜单
void MainWindow::initMenu(){
    ui->MenuListWidget->addItems(menuList);
    connect(ui->MenuListWidget, &QListWidget::itemClicked,this, &MainWindow::onMenuItemClicked);

}
//listview 点击回调
void MainWindow::onMenuItemClicked( QListWidgetItem * item){

    int index = ui->MenuListWidget->row( item );
    qDebug() << "点击了菜单项:" << item->text() << ",index:" << index;

}
MainWindow::~MainWindow()
{
    delete ui;
}

